package com.sghd.fight.module.game.service.room;

import com.sghd.common.utils.model.RatioProbability;
import com.sghd.fight.module.game.config.LevelConfig;
import com.sghd.fight.module.game.config.MonsterConfig;
import com.sghd.fight.module.game.core.model.Unit;
import com.sghd.pojo.fight.game.ChessType;
import com.sghd.pojo.fight.game.UnitEnum;
import com.sghd.pojo.fight.game.UnitValue;
import com.sghd.pojo.fight.game.UnitVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class Monster extends Unit{

    protected Logger logger = LoggerFactory.getLogger(getClass());

    private MonsterConfig monsterConfig;
    /** 怪物技能权重辅助类*/
    private RatioProbability<Integer> weight2Skill;

    //TODO 怪物名称 ID 血量 技能   /  关卡普通行动 特殊行动

    public Monster(MonsterConfig monsterConfig, IRoom room, LevelConfig levelConfig) {
        super(monsterConfig.getId(), monsterConfig.getMonsterName(), room);
        this.type = UnitEnum.ROBOT;
        ready = true;
        super.values.put(UnitValue.HP,levelConfig.getHp());
        super.values.put(UnitValue.HP_MAX,levelConfig.getHpMax());
        weight2Skill = RatioProbability.valueOf(levelConfig.getMonsterSkills());
        for (Map.Entry<ChessType, Integer> entry : magic.getMagics().entrySet()) {
            magic.update(entry.getKey(), -entry.getValue());
        }
    }

    public RatioProbability<Integer> getWeight2Skill() {
        return weight2Skill;
    }

    public void setWeight2Skill(RatioProbability<Integer> weight2Skill) {
        this.weight2Skill = weight2Skill;
    }

    public MonsterConfig getMonsterConfig() {
        return monsterConfig;
    }

    public void setMonsterConfig(MonsterConfig monsterConfig) {
        this.monsterConfig = monsterConfig;
    }

    @Override
    public UnitVo toVo() {
        UnitVo unitVo = super.toVo();
        Map<UnitValue, Integer> values = new HashMap<>();
        values.put(UnitValue.HP, super.values.get(UnitValue.HP));
        values.put(UnitValue.HP_MAX, super.values.get(UnitValue.HP_MAX));
        unitVo.setValues(values);
        return unitVo;
    }
    public static void main(String[] args) {

    }
}
